<script>

//辅助函数
import {mapActions, mapGetters, mapMutations, mapState} from "vuex";

  export default {
    name: "Home",
    methods: {
      handleClick() {
        //调用store mutation的方法
        this.$store.commit('change',5)
        //调用store action的方法
        this.$store.dispatch('change',5)
      },

      //调用store action的方法
      ...mapActions(['change']),

      //调用store mutation的方法
      ...mapMutations(['change']),
    },
    computed:{
      doubleCount(){
        return this.$store.getters.doubleCount
      },
      count(){
        return this.$store.state.count
      },

      //辅助函数
      ...mapState(['count']),

      ...mapGetters(['doubleCount'])
    }
  }
</script>

<template>
  <div>Home.vue
    <button @click="handleClick">点击</button>
    <button @click="change(5)">辅助函数点击</button>

    computed: {{count}} , {{doubleCount}} |
    state: {{$store.state.count}},{{$store.getters.doubleCount}}
  </div>
</template>

<style scoped>

</style>